From 2a869011d4ee6e0adf5246734d148e7ad68a0d84 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 12 Oct 2011 17:11:28 +0100 Subject: [PATCH] Revert part of 23811:f1349a968a5a "ns16550: Simplify UART..." The change to poll LSR.THRE in a loop from __ns16550_poll is a bug. We can loop indefinitely if there are no chars to transmit. Thanks to Jan for spotting it. Signed-off-by: Keir Fraser --- xen/drivers/char/ns16550.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 492c9bf44d..e09e30ddef 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -157,18 +157,15 @@ static void __ns16550_poll(struct cpu_user_regs *regs) { struct serial_port *port = this_cpu(poll_port); struct ns16550 *uart = port->uart; - char lsr; if ( uart->intr_works ) return; /* Interrupts work - no more polling */ - while ( (lsr = ns_read_reg(uart, LSR)) & (LSR_DR|LSR_THRE) ) - { - if ( lsr & LSR_THRE ) - serial_tx_interrupt(port, regs); - if ( lsr & LSR_DR ) - serial_rx_interrupt(port, regs); - } + while ( ns_read_reg(uart, LSR) & LSR_DR ) + serial_rx_interrupt(port, regs); + + if ( ns_read_reg(uart, LSR) & LSR_THRE ) + serial_tx_interrupt(port, regs); set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms)); } -- 2.30.2